﻿//alert("hi there");

function doAlert() {
    //alert("did alert");
    console.log("nailed it");

}

doAlert();
var myAlert = function () {
    console.log("yippie");
}
myAlert();

//Methods (method is on an object)
var cat = {
    isClean: false,
    doClean: function () { this.isClean = true },
    doFeed: function (){console.log("just eat")}
};
console.log(cat);
cat.doClean();
console.log(cat);

//inheriting methos from other objects
var kitten = {
    isClean: false
}
kitten.__proto__ = cat;
kitten.clean();

//Constructor
var Car = function (color, model) {
    this.color = color,
    this.model = model
}
var bug = new Car("yeller", "beetle");
var beemer = new Car("black", "bmw");

//Arguements
var argCheck = function () {
    console.log(arguments);
    var tempSum = 0;
    for (var i = 0; i < arguments.length; i++) {
        console.log("arg: ", arguments[i];
        tempSum += arguments[i];


    }
    console.log(tempSum);
    return tempSum;

}
var myTotal = argCheck(5,10,15,20);
// 
var tTotal = (function(){
    return arguments[0]+ arguments[1];
})(5,5);
var finalTotal = tTotal()

//Scope

var myScope = "global";
(function(){
    var myScope = "function";
    alert(myScope);
})();
alert(myScope);
